function [n,fracsPar,aUpdate, obs_error, T_cal] = frac_update (mcmcPar, frac_info)

    sigma=mcmcPar.sig;
    measurements=mcmcPar.obs;
    aUpdate=0;
    aperture = frac_info (1,7);
    [~,fx_old,~] = THERMAID (frac_info, aperture);  
    [d_error, log_likeli_old] = Likelihood(fx_old,sigma,measurements);
    T_cal=fx_old;
    for t =1: mcmcPar.innerloop
        
        apert_new  =  10^(2.0*rand(1)-4.0);
        %%-----------genenerate a new aperture --------------------
%         apmean = aperture;
%         apSD = 1;
%         untruncated = makedist('Normal',apmean,apSD);
%         truncated = truncate(untruncated,-4,-2);
%         apert_new = random(truncated,1);
%         %----------------------------------------------------------
        
        [~,fx_new,~]= THERMAID (frac_info, apert_new); 
        [d_error_new, log_likeli_new] = Likelihood(fx_new,sigma,measurements);

%% -------------- metropolis judgement --------------------------
        ratio= exp(log_likeli_new-log_likeli_old);  
        acceptance = min(1,ratio);   

        uB=rand(1);
        if (uB<acceptance)
            log_likeli_old = log_likeli_new;
            d_error  = d_error_new;
            aperture = apert_new;
            aUpdate=aUpdate+1;
            T_cal=fx_new;
        end
        
    end
    
    obs_error=d_error;
    frac_info(:,end)=aperture;
    fracsPar=frac_info;
    n=size(fracsPar,1);
    aUpdate=aUpdate/mcmcPar.innerloop;

end
